using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SIGCBI.Entities;

namespace SIGCBI.Repository.Mapping
{
    public class AREAMap : EntityTypeConfiguration<CENTRO_COSTO>
    {
        public AREAMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(p => p.ID).
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.Descripcion)
                .HasMaxLength(100);

            this.Property(t => t.Codigo)
                .HasMaxLength(7);

            // Table & Column Mappings
            this.ToTable("CENTRO_COSTO");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Descripcion).HasColumnName("Descripcion");
            this.Property(t => t.Codigo).HasColumnName("Codigo");
            this.Property(t => t.IdTrabajador).HasColumnName("IdTrabajador");
            //this.Property(t => t.Discriminator).HasColumnName("Discriminator");

            // Relationships
            this.HasRequired(t => t.TRABAJADOR)
                .WithMany(t => t.CENTRO_COSTOs)
                .HasForeignKey(d => d.IdTrabajador)
                .WillCascadeOnDelete(false);

        }
    }
}
